package org.example.crm.clue;

import com.sun.deploy.net.FailedDownloadException;
import lombok.Data;

import javax.naming.ldap.PagedResultsControl;
@Data
public class Result<T> {
    public static final int  SUCCESS = 200;
    public static final int FAILED = 500;

    private int code = SUCCESS;
    private String message = "successe";

    private T date;

    private Result(int code, String message, T date) {
        this.code = code;
        this.message = message;
        this.date = date;
    }

    public static Result ok(){
        return new Result(SUCCESS,"success",null);
    }

    public static <T> Result<T> ok(int code,String message){
        return new Result(code,message,null);
    }

    public static  <T> Result<T> ok(T date){
        return new Result(SUCCESS,"success",date);
    }

    public static Result error(){
        return new Result(FAILED,"error",null);
    }

    public static <T> Result<T> error(int code,String message){
        return new Result(code,message,null);
    }

    public static  <T> Result<T> error(String message){
        return new Result(FAILED,message,null);
    }
}
